import request from '@/utils/request';

// 首页数据
// 一级分类
export interface homeOneModel {
    data: homeTowModel,
    code: string
}
// 二级分类
export interface homeTowModel {
    data: homeThreeModel,
    noticeList: []
}
// 网易自营品牌
export interface SelfOperatedList {
    icon: string,
    schemeUrl: string,
    desc: string,
}

// 首页中标签页---子目录
export interface labelDatachildList {
    picUrl: string,
    schemeUrl: string,
    text: string,
    textColor: string
}
// 首页中标签页
export interface labelDataList {
    norColor: string,
    background: string,
    kingKongList: labelDatachildList[],
    selectedColor: string
}

// 轮播
export interface CarouselList {
    picUrl: string,
    expireTime: number,
    extra: any,
    name: string,
    onlineTime: number,
    id: number,
    originSchemeUrl: string,
    targetUrl: string
}

export interface ItemList {
    primarySkuPreSellStatus: number
    picUrl: string
    pieceUnitDesc: string
    pieceNum: number
    colorNum: number
    schemeUrl: string
    primarySkuPreSellPrice: number
    id: number
}

export interface Extra {
    crmType: number
    resource: Resource
    modelType: number
}
export interface Resource {
    materialContentFrom: number
    materialName: string
    rcmdSort: boolean
    taskType: number
    itemFrom: number
    crmUserGroupName: string
    resourcesId: number
    materialType: string
    schemeUrl: string
    crmUserGroupId: string
    materialId: string
    taskId: string
}
// 周年狂欢---孙
export interface Cell {
    subTitleColor: string
    rcmdItem: boolean
    schemeUrl: string
    title: string
    picUrl: string
    rcmdSort: boolean
    itemCnt: number
    itemFrom: number
    subTitle: string
    titleColor: string
    showPrice: boolean
    extra: Extra
    popupUrl: string
    leftTime: number
    itemList: ItemList[]
    id: string
    targetUrl: string
}

// 周年狂欢---子
export interface FloorList {
    layout: number
    cells: Cell[]
    columnNum: number
    floorType: number
    style: number
    taskId: number
    height: number
}

// 周年狂欢
export interface BigPromotionModule {
    floorList: FloorList[]
}


export interface TagList {
    floorPrice: number
    picUrl: string
    newOnShelf: boolean
    webIndexVerticalPicUrl: string
    simpleDesc: string
    name: string
    appListPicUrl: string
    id: number
}

// 类目排行榜
export interface CategoryHotSellModule {
    titleTargetUrl: string
    categoryList: CategoryList[]
    title: string
}
export interface CategoryList {
    picUrl: string
    extra: Extra2
    itemPicBeanList: ItemPicBeanList[]
    categoryName: string
    targetUrl: string
    showPicUrl: string
}
export interface ItemPicBeanList {
    itemId: number
    picUrl: string
}
export interface Extra2 {
    crmType: number
    operationResource: OperationResource
    modelType: number
}
export interface OperationResource {
    itemIdList: string[]
    categoryName: string
    categoryId: string
}

export interface SceneLightShoppingGuideModule {
    styleBanner?: StyleBanner
    styleItem?: StyleItem
}
export interface StyleItem {
    descColor: string
    itemFrom: number
    picUrlList: string[]
    titleColor: string
    extra: Extra4
    itemPicBeanList: ItemPicBeanList[]
    originSchemeUrl: string
    title: string
    targetUrl: string
    desc: string
}
export interface StyleBanner {
    descColor: string
    picUrl: string
    titleColor: string
    extra: Extra4
    originSchemeUrl: string
    title: string
    targetUrl: string
    desc: string
}

export interface Extra4 {
    materialContentFrom: number
    materialName: string
    rcmdSort: boolean
    taskType: number
    itemFrom: number
    crmUserGroupName: string
    resourcesId: number
    materialType: string
    crmUserGroupId: string
    materialId: string
    taskId: string
}

// 新人专享礼
export interface IndexActivityModule {
    backgroundUrl?: string
    picUrl: string
    activityPrice: string
    subTitle: string
    originPrice: string
    tag: string
    title: string
    targetUrl: string
    showPicUrl: string
}

// 三级分类
export interface homeThreeModel {
    bigPromotionModule: BigPromotionModule, // 周年狂欢
    tagList: TagList[],
    policyDescList: SelfOperatedList[], // 网易自营品牌
    popularItemList: any[],
    categoryHotSellModule: CategoryHotSellModule,// 类目排行榜
    freshmanFlag: boolean,
    focusList: CarouselList[], // 轮播
    sceneLightShoppingGuideModule: SceneLightShoppingGuideModule[],
    kingKongModule: labelDataList, // 首页中标签页
    indexActivityModule: IndexActivityModule[], // 新人专享礼
}



//为你精选
export interface ItemsParams {
    itemIdsStr: string;
    size: number;
}
export interface DataTuList {
    code: number
    data: RootObject
    error: null
    message: null
}
export interface RootObject {
    itemList: ItemLists[];
    itemIdsStr: string;
    rcmdVer: string;
    hasMore: boolean;
}

export interface ItemLists {
    id: number;
    listPicUrl: string;
    name: string;
    seoTitle: string;
    simpleDesc: string;
    primaryPicUrl: string;
    primarySkuId: number;
    retailPrice?: any;
    counterPrice?: any;
    sortOriginPrice?: any;
    status: number;
    rank: number;
    soldOut: boolean;
    underShelf: boolean;
    updateTime: number;
    sellVolume: number;
    newItemFlag: boolean;
    primarySkuPreSellPrice?: any;
    primarySkuPreSellStatus: number;
    pieceNum: number;
    pieceUnitDesc: string;
    colorNum: number;
    limitedFlag: number;
    promId: number;
    preLimitFlag: number;
    productPlace: string;
    flashPageLink: string;
    promotionDesc: string;
    specialPromTag: string;
    extraPrice: string;
    appExclusiveFlag: boolean;
    itemTagList?: ItemTagList[];
    isPreemption: number;
    preemptionStatus: number;
    buttonType: number;
    showTime: number;
    onSaleTime: number;
    itemPromValid: boolean;
    autoOnsaleTime: number;
    autoOnsaleTimeLeft: number;
    displaySkuId: number;
    presentUrl?: any;
    saleCenterSkuId: number;
    itemType: number;
    points: number;
    showPoints: boolean;
    pointsPrice: number;
    forbidExclusiveCal: boolean;
    commentCount: number;
    commentWithPicCount: number;
    itemSizeTableFlag: boolean;
    itemSizeTableDetailFlag: boolean;
    jumpUrl?: any;
    zcSearchFlag: boolean;
    pointsStatus: number;
    sortFlag: number;
    source: number;
    scenePicUrl: string;
    couponPrice?: any;
    couponConflict: boolean;
    extraServiceFlag: number;
    forbiddenBuy: boolean;
    forbidBuyDesc?: any;
    spmcOpenGiftItemDesc?: any;
    discountDesc?: any;
    subtractPriceDesc?: any;
    goodCmtRate?: any;
    showCommentEntrance: boolean;
    categoryL2Id: number;
    promLogo?: any;
    promoTip?: any;
    rewardShareFlag: boolean;
    promDesc?: any;
    picMode: number;
    extra?: any;
    shieldSpecialChannel: boolean;
    freeTryId: number;
    zoomTransPicV2Url: string;
    finalPriceInfoVO: FinalPriceInfoVO;
    topLogo?: TopLogo;
    preLogo: TopLogo[];
    showPrice: boolean;
    pointTag?: any;
    pointTagExtra?: any;
    pointTagPrefix?: any;
    zc: boolean;
    wapSchemeUrl?: any;
    listProPriceInfoDTO?: any;
}

export interface TopLogo {
    logoUrl: string;
    width: number;
    height: number;
    type: number;
}

export interface FinalPriceInfoVO {
    banner?: Banner;
    priceInfo: PriceInfo;
    type: number;
}

export interface PriceInfo {
    finalPrice?: FinalPrice;
    counterPrice?: string;
    basicPrice: string;
}

export interface FinalPrice {
    prefix?: string;
    price: string;
    suffix?: any;
}

export interface Banner {
    logo?: any;
    title?: string;
    price?: any;
    content: string;
}

export interface ItemTagList {
    type: number;
    name: string;
    color?: any;
    iconUrl?: any;
    iconRate: number;
    itemTag?: any;
    itemTagType?: any;
    promId: number;
    itemId: number;
    freshmanExclusive: boolean;
    sortRank: number;
}



export default {
    // 首页数据
    getHomeList() {
        return request.get<any, homeOneModel>('/xhr/index.json?__timestamp=1630131808529')
    },
    //为你精选
    getHomeItems(params: ItemsParams) {
        return request.post<any, DataTuList>(`/xhr/index/items.json`, params)
    },

}